package jacob;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;

public class Lighting_Sword extends ItemSword {

	public Lighting_Sword(int par1, EnumToolMaterial par2EnumToolMaterial) {
		super(par1, par2EnumToolMaterial);
		// TODO Auto-generated constructor stub
		
	}
	 public void registerIcons(IconRegister iconReg)
	    {
	        itemIcon = iconReg.registerIcon("iDTechModBase:LightningSword");
	        
	    }
	
	/**
	 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
	 */
	 public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
	    {
	        par1ItemStack.damageItem(3, par3EntityLiving);
	        /*
	        this.potionID = par1;
	        this.duration = par2;
	        this.amplifier = par3;
	        this.isAmbient = par4;
	        */
	        //if ((EntitySkeleton)par2EntityLiving  != null)
	        //{
	        //      par2EntityLiving.addPotionEffect(new PotionEffect(Potion.heal.id, 5000, 1, false));
	        //}
	        // if ((EntityZombie)par2EntityLiving != null)
	        //{
	                //par2EntityLiving.addPotionEffect(new PotionEffect(Potion.heal.id, 5000, 1, false));
	        //}
	       // par2EntityLiving.addPotionEffect(new PotionEffect(Potion.jump.id, 300 , 200, false));
	        return true;
	        
	    }
	 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
	{
	    /*
	    if (!par3EntityPlayer.capabilities.isCreativeMode)
	    {
	        --par1ItemStack.stackSize;
	    }
	    */
	    par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
	
	    if (!par2World.isRemote)
	    {
	            //par3EntityPlayer.entityDropItem(par1ItemStack, par2)
	    	     Vec3 skeyPos = util.placeInFrontOfEntity(par3EntityPlayer, 10);
	    	     skeyPos.yCoord = par2World.getPrecipitationHeight((int)skeyPos.xCoord,(int) skeyPos.zCoord);
	            EntityLightningBolt skeley = (EntityLightningBolt)new EntityLightningBolt(par2World, skeyPos.xCoord, skeyPos.yCoord, skeyPos.zCoord);
	            /*
	            skeley.setPosition(par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ);
	            skeley.rotationYaw = par3EntityPlayer.rotationYaw - 90;
	            skeley.posX -= ((double)(MathHelper.cos(skeley.rotationYaw / 180.0F * (float)Math.PI) * 0.16F)) * 100;
	        skeley.posZ -= ((double)(MathHelper.sin(skeley.rotationYaw / 180.0F * (float)Math.PI) * 0.16F)) * 100;
	        */
	            
	           
	           par2World.addWeatherEffect(skeley);
	    }
	    super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer);
	    
	
	    return par1ItemStack;
	}
		public int getDamageVsEntity(Entity par1Entity)
		{
			return 6;
		}
		
		
}

